<!DOCTYPE html>
<!-- saved from url=(0054)https://www.cnblogs.com/dee0912/p/5815267.html#_label1 -->
<html lang="zh-cn"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="referrer" content="origin">
    <meta name="description" content="① 安装 Git Linux 做为服务器端系统，Windows 作为客户端系统，分别安装 Git 服务器端： 安装完后，查看 Git 版本 客户端： 下载 Git for Windows，地址：htt">
    <meta property="og:description" content="① 安装 Git Linux 做为服务器端系统，Windows 作为客户端系统，分别安装 Git 服务器端： 安装完后，查看 Git 版本 客户端： 下载 Git for Windows，地址：htt">
    <meta http-equiv="Cache-Control" content="no-transform">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>在 Linux 下搭建 Git 服务器 - deee - 博客园</title>
    <link id="favicon" rel="shortcut icon" href="https://common.cnblogs.com/favicon.svg" type="image/svg+xml">
    
    <link rel="stylesheet" href="./在 Linux 下搭建 Git 服务器_files/blog-common.min.css">
    <link id="MainCss" rel="stylesheet" href="./在 Linux 下搭建 Git 服务器_files/bundle-lessismoreright.min.css">
    
    <link id="mobile-style" media="only screen and (max-width: 767px)" type="text/css" rel="stylesheet" href="./在 Linux 下搭建 Git 服务器_files/bundle-lessismoreright-mobile.min.css">
    
    <link type="application/rss+xml" rel="alternate" href="https://www.cnblogs.com/dee0912/rss">
    <link type="application/rsd+xml" rel="EditURI" href="https://www.cnblogs.com/dee0912/rsd.xml">
    <link type="application/wlwmanifest+xml" rel="wlwmanifest" href="https://www.cnblogs.com/dee0912/wlwmanifest.xml">
    <script src="./在 Linux 下搭建 Git 服务器_files/hm.js"></script><script async="" src="./在 Linux 下搭建 Git 服务器_files/analytics.js"></script><script type="text/javascript" src="./在 Linux 下搭建 Git 服务器_files/encoder.js"></script><script>
        var currentBlogId = 196695;
        var currentBlogApp = 'dee0912';
        var cb_enable_mathjax = false;
        var isLogined = false;
        var isBlogOwner = false;
        var skinName = 'LessIsMoreRight';
        var visitorUserId = '';
    </script>
        <script>
            var currentPostDateAdded = '2016-08-28 11:36';
        </script>
    <script src="./在 Linux 下搭建 Git 服务器_files/jquery-2.2.0.min.js"></script>
    <script src="./在 Linux 下搭建 Git 服务器_files/blog-common.min.js"></script>
    
    
    
</head>
<body class="has-navbar has-bannerbar">
    <a name="top"></a>
            <div id="bannerbar" class="bannerbar-mobile formobile">
                <a href="https://www.cnblogs.com/cmt/p/14152738.html" target="_blank" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;sephora-mobile-bannerbar&#39;)">
                    <img src="./在 Linux 下搭建 Git 服务器_files/35695-20201220150807860-80833722.png" alt="">
                </a>
            </div>
    <div id="top_nav" class="navbar forpc">
        <nav id="nav_main" class="navbar-main">
            <ul id="nav_left" class="navbar-list navbar-left">
                <li class="navbar-branding"><a href="https://www.cnblogs.com/" title="开发者的网上家园"><img src="./在 Linux 下搭建 Git 服务器_files/logo.svg" alt="博客园Logo"></a></li>
                <li><a href="https://www.cnblogs.com/" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;skin-navbar-sitehome&#39;)">首页</a></li>
                <li><a href="https://news.cnblogs.com/" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;skin-navbar-news&#39;)">新闻</a></li>
                <li><a href="https://q.cnblogs.com/" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;skin-navbar-q&#39;)">博问</a></li>
                <li><a id="nav_brandzone" href="https://brands.cnblogs.com/" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;skin-navbar-brands&#39;)">专区</a></li>
                <li><a href="https://ing.cnblogs.com/" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;skin-navbar-ing&#39;)">闪存</a></li>
                <li><a href="https://edu.cnblogs.com/" onclick="ga(&#39;send&#39;, &#39;event&#39;, &#39;Link&#39;, &#39;click&#39;, &#39;skin-navbar-edu&#39;)">班级</a></li>
            </ul>
            <ul id="nav_right" class="navbar-list navbar-right">
                <li>
                    <form id="zzk_search" class="navbar-search" action="https://zzk.cnblogs.com/s" method="get">
                        <input name="w" id="zzk_search_input" placeholder="代码改变世界" type="text" tabindex="3">
                        <button type="submit" id="zzk_search_button">
                            <img src="./在 Linux 下搭建 Git 服务器_files/search.svg" alt="搜索">
                        </button>
                    </form>
                </li>
                <li id="navbar_login_status" class="navbar-list">
                    <a id="navblog-myblog-icon" class="navbar-user-info navbar-blog" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx" alt="我的博客" title="我的博客" style="display: none;">
                        <img id="myblog_icon" class="navbar-icon" src="./在 Linux 下搭建 Git 服务器_files/myblog.svg" alt="我的博客">
                    </a>
                    <a class="navbar-user-info navbar-message navbar-icon-wrapper" href="https://msg.cnblogs.com/" alt="短消息" title="短消息" style="display: none;">
                        <img id="msg_icon" class="navbar-icon" src="./在 Linux 下搭建 Git 服务器_files/message.svg" alt="短消息">
                        <span id="msg_count" style="display: none"></span>
                    </a>
                    <div id="user_info" class="navbar-user-info dropdown" style="display: none;">
                        <a class="dropdown-button" href="https://home.cnblogs.com/">
                            <img id="user_icon" class="navbar-avatar" src="./在 Linux 下搭建 Git 服务器_files/avatar-default.svg" alt="用户头像">
                        </a>
                        <div class="dropdown-menu">
                            <a id="navblog-myblog-text" href="https://passport.cnblogs.com/GetBlogApplyStatus.aspx">我的博客</a>
                            <a href="https://home.cnblogs.com/">我的园子</a>
                            <a href="https://account.cnblogs.com/settings/account">账号设置</a>
                            <a href="javascript:void(0)" onclick="logout();">退出登录</a>
                        </div>
                    </div>
                    <a class="navbar-anonymous" href="https://account.cnblogs.com/signup/" style="display: inline;">注册</a>
                    <a class="navbar-anonymous" href="javascript:void(0);" onclick="login()" style="display: inline;">登录</a>
                </li>
            </ul>
        </nav>
    </div>

    <div id="page_begin_html"><script type="text/javascript">window['__document_write_ajax_callbacks__']['2']();</script><script>window['__document_write_ajax_callbacks__']['1']();</script></div>
    <div id="home">
    <div id="header">
        <div id="blogTitle">
            <div class="title"><a id="Header1_HeaderTitle" class="headermaintitle HeaderMainTitle" href="https://www.cnblogs.com/dee0912/">Meadows of Heaven</a>
</div>
<div class="subtitle">厚积薄发</div>

        </div>
        <div id="navigator">
            
<ul id="navList">
    <li id="nav_sitehome">
</li>
    <li id="nav_myhome">
<a id="blog_nav_myhome" class="menu" href="https://www.cnblogs.com/dee0912/">
首页</a>
</li>
    <li id="nav_newpost">

<a id="blog_nav_newpost" class="menu" href="https://i.cnblogs.com/EditPosts.aspx?opt=1">
新随笔</a>
</li>
    <li id="nav_contact">
</li>
    <li id="nav_rss">
</li>
    <li id="nav_admin">
<a id="blog_nav_admin" class="menu" href="https://i.cnblogs.com/">
管理</a>
</li>
</ul>

            <div class="blogStats">
                
<span id="stats_post_count">随笔 - 310&nbsp;</span>
<span id="stats_article_count">文章 - 67&nbsp;</span>
<!-- <span id="stats-comment_count"></span> -->
<span id="stats_comment_count">评论 - 65</span>
            </div>
        </div>
    </div>
    <div id="main">
        <div id="mainContent">
            <div class="forFlow">
                <div id="post_detail">
    <div id="topics">
        <div class="post">
            <h1 class="postTitle">
                
<a id="cb_post_title_url" class="postTitle2 vertical-middle" href="https://www.cnblogs.com/dee0912/p/5815267.html">
    <span>在 Linux 下搭建 Git 服务器</span>
    


</a>

            </h1>
            <div class="clear"></div>
            <div class="postBody">
                
<div id="cnblogs_post_body" class="blogpost-body"><a name="_labelTop"></a><div id="navCategory"><p style="font-size:18px"><b>目录</b></p><ul><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label0">① 安装 Git</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label1">② 服务器端创建 git 用户，用来管理 Git 服务，并为 git 用户设置密码</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label2">③ 服务器端创建 Git 仓库</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label3">④ 客户端 clone 远程仓库</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label4">⑤ 客户端创建 SSH 公钥和私钥</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label5">⑥ 服务器端 Git 打开 RSA 认证</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label6">⑦ 将客户端公钥导入服务器端 /home/git/.ssh/authorized_keys 文件</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label7">⑧ 客户端再次&nbsp;clone 远程仓库</a></li><li><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_label8">⑨ 禁止 git 用户 ssh 登录服务器</a></li></ul></div><p>&nbsp;</p><p style="font-size:18px"><b>正文</b></p>
    <div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">环境：</span><span style="color: rgba(0, 0, 0, 1)">
服务器 CentOS6.6 + git（version </span><span style="color: rgba(128, 0, 128, 1)">1.7</span>.<span style="color: rgba(128, 0, 128, 1)">1）<br><span style="color: rgba(0, 0, 0, 1)">客户端 Windows10 + </span></span>git（version 2.8.4.windows.1）</pre>
</div>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label0"></a></div><h2>① 安装 Git</h2>
<p>Linux 做为服务器端系统，Windows 作为客户端系统，分别安装 Git</p>
<p><strong>服务器端：</strong></p>
<div class="cnblogs_code">
<pre>#yum install -y git</pre>
</div>
<p>安装完后，查看 Git 版本</p>
<div class="cnblogs_code">
<pre>[root@localhost ~]# git --<span style="color: rgba(0, 0, 0, 1)">version
git version </span><span style="color: rgba(128, 0, 128, 1)">1.7</span>.<span style="color: rgba(128, 0, 128, 1)">1</span></pre>
</div>
<p>&nbsp;</p>
<p><strong>客户端：</strong></p>
<p>下载 <a href="https://github.com/git-for-windows/git/releases/download/v2.9.3.windows.2/Git-2.9.3.2-64-bit.exe" target="_blank">Git for Windows</a>，地址：<a href="https://git-for-windows.github.io/" target="_blank">https://git-for-windows.github.io/</a></p>
<p>安装完之后，可以使用 Git Bash 作为命令行客户端。</p>
<p>安装完之后，查看 Git 版本</p>
<div class="cnblogs_code">
<pre>$ git --<span style="color: rgba(0, 0, 0, 1)">version
git version </span><span style="color: rgba(128, 0, 128, 1)">2.8</span>.<span style="color: rgba(128, 0, 128, 1)">4</span>.windows.<span style="color: rgba(128, 0, 128, 1)">1</span></pre>
</div>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label1"></a></div><h2>② 服务器端创建 git 用户，用来管理 Git 服务，并为 git 用户设置密码</h2>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">[root@localhost home]# id git
id: git：无此用户
[root@localhost home]# useradd git
[root@localhost home]# passwd git<br></span></pre>
</div>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label2"></a></div><h2>③ 服务器端创建 Git 仓库</h2>
<p>设置 /home/data/git/gittest.git 为 Git 仓库</p>
<p>然后把 Git 仓库的 owner 修改为 git</p>
<div class="cnblogs_code">
<pre>[root@localhost home]# mkdir -p data/git/<span style="color: rgba(0, 0, 0, 1)">gittest.git
[root@localhost home]# git init </span>--bare data/git/<span style="color: rgba(0, 0, 0, 1)">gittest.git
Initialized empty Git repository </span><span style="color: rgba(0, 0, 255, 1)">in</span> /home/data/git/gittest.git/<span style="color: rgba(0, 0, 0, 1)">
[root@localhost home]# cd data</span>/git/<span style="color: rgba(0, 0, 0, 1)">
[root@localhost git]# chown </span>-R git:git gittest.git/</pre>
</div>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label3"></a></div><h2>④ 客户端 clone 远程仓库</h2>
<p>进入 Git Bash 命令行客户端，创建项目地址（设置在 d:/wamp64/www/gittest_gitbash）并进入:</p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./在 Linux 下搭建 Git 服务器_files/copycode.gif" alt="复制代码"></a></span></div>
<pre>dee@Lenovo-PC MINGW64 /<span style="color: rgba(0, 0, 0, 1)">d
$ cd wamp64</span>/<span style="color: rgba(0, 0, 0, 1)">www

dee@Lenovo</span>-PC MINGW64 /d/wamp64/<span style="color: rgba(0, 0, 0, 1)">www
$ mkdir gittest_gitbash

dee@Lenovo</span>-PC MINGW64 /d/wamp64/<span style="color: rgba(0, 0, 0, 1)">www
$ cd gittest_gitbash

dee@Lenovo</span>-PC MINGW64 /d/wamp64/www/<span style="color: rgba(0, 0, 0, 1)">gittest_gitbash
$</span></pre>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./在 Linux 下搭建 Git 服务器_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<p>然后从 Linux Git 服务器上 clone 项目：</p>
<div class="cnblogs_code">
<pre>$ git clone git@192.168.56.101:/home/data/gittest.git</pre>
</div>
<p>如果SSH用的不是默认的22端口，则需要使用以下的命令（假设SSH端口号是7700）：</p>
<div class="cnblogs_code">
<pre>$ git clone ssh://git@192.168.56.101:7700/home/data/gittest.git</pre>
</div>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828224409166-1327160680.png" alt="">　　</p>
<p>当第一次连接到目标 Git 服务器时会得到一个提示：</p>
<div class="cnblogs_code">
<pre>The authenticity of host <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">192.168.56.101 (192.168.56.101)</span><span style="color: rgba(128, 0, 0, 1)">'</span> can<span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">t be established.</span>
RSA key fingerprint <span style="color: rgba(0, 0, 255, 1)">is</span> SHA256:Ve6WV/<span style="color: rgba(0, 0, 0, 1)">SCA059EqoUOzbFoZdfmMh3B259nigfmvdadqQ.
Are you sure you want to </span><span style="color: rgba(0, 0, 255, 1)">continue</span> connecting (yes/no)? </pre>
</div>
<p>选择 yes：</p>
<div class="cnblogs_code">
<pre>Warning: Permanently added <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">192.168.56.101</span><span style="color: rgba(128, 0, 0, 1)">'</span> (RSA) to the list of known hosts.</pre>
</div>
<p>此时&nbsp;C:\Users\用户名\.ssh 下会多出一个文件&nbsp;known_hosts，以后在这台电脑上再次连接目标 Git 服务器时不会再提示上面的语句。</p>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828225138698-412131557.png" alt=""></p>
<p>后面提示要输入密码，可以采用 SSH 公钥来进行验证。</p>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label4"></a></div><h2>⑤ 客户端创建 SSH 公钥和私钥</h2>
<div class="cnblogs_code">
<pre>$ ssh-keygen -t rsa -C <span style="color: rgba(128, 0, 0, 1)">"</span><span style="color: rgba(128, 0, 0, 1)">472323087@qq.com</span><span style="color: rgba(128, 0, 0, 1)">"</span></pre>
</div>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828225309533-1152112221.png" alt=""></p>
<p>此时&nbsp;C:\Users\用户名\.ssh 下会多出两个文件&nbsp;id_rsa 和&nbsp;id_rsa.pub</p>
<p>id_rsa 是私钥</p>
<p>id_rsa.pub 是公钥</p>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828225436257-770631205.png" alt="" width="890" height="356"></p>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label5"></a></div><h2>⑥ 服务器端 Git 打开 RSA 认证</h2>
<p>进入 /etc/ssh 目录，编辑 sshd_config，打开以下三个配置的注释：</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh</span>/authorized_keys</pre>
</div>
<p>保存并重启 sshd 服务：</p>
<div class="cnblogs_code">
<pre>[root@localhost ssh]# /etc/rc.d/init.d/sshd restart</pre>
</div>
<p>&nbsp;</p>
<p>由 AuthorizedKeysFile 得知公钥的存放路径是 .ssh/authorized_keys，实际上是 $Home/.ssh/authorized_keys，由于管理&nbsp;Git 服务的用户是 git，所以实际存放公钥的路径是 /home/git/.ssh/authorized_keys</p>
<p>在 /home/git/ 下创建目录 .ssh</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">[root@localhost git]# pwd
</span>/home/<span style="color: rgba(0, 0, 0, 1)">git<br></span>[root@localhost git]# mkdir .ssh<br><span>[root@localhost git]# ls </span>-<span>a <br>. .. .bash_logout .bash_profile .bashrc .gnome2 .mozilla .ssh</span></pre>
</div>
<p>然后把 .ssh 文件夹的 owner 修改为 git</p>
<div class="cnblogs_code"><div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./在 Linux 下搭建 Git 服务器_files/copycode.gif" alt="复制代码"></a></span></div>
<pre>[root@localhost git]# chown -<span style="color: rgba(0, 0, 0, 1)">R git:git .ssh
[root@localhost git]# ll </span>-<span style="color: rgba(0, 0, 0, 1)">a
总用量 </span><span style="color: rgba(128, 0, 128, 1)">32</span><span style="color: rgba(0, 0, 0, 1)">
drwx</span>------. <span style="color: rgba(128, 0, 128, 1)">5</span> git  git  <span style="color: rgba(128, 0, 128, 1)">4096</span> 8月  <span style="color: rgba(128, 0, 128, 1)">28</span> <span style="color: rgba(128, 0, 128, 1)">20</span>:<span style="color: rgba(128, 0, 128, 1)">04</span><span style="color: rgba(0, 0, 0, 1)"> .
drwxr</span>-xr-x. <span style="color: rgba(128, 0, 128, 1)">8</span> root root <span style="color: rgba(128, 0, 128, 1)">4096</span> 8月  <span style="color: rgba(128, 0, 128, 1)">28</span> <span style="color: rgba(128, 0, 128, 1)">19</span>:<span style="color: rgba(128, 0, 128, 1)">32</span><span style="color: rgba(0, 0, 0, 1)"> ..
</span>-rw-r--r--. <span style="color: rgba(128, 0, 128, 1)">1</span> git  git    <span style="color: rgba(128, 0, 128, 1)">18</span> 10月 <span style="color: rgba(128, 0, 128, 1)">16</span> <span style="color: rgba(128, 0, 128, 1)">2014</span><span style="color: rgba(0, 0, 0, 1)"> .bash_logout
</span>-rw-r--r--. <span style="color: rgba(128, 0, 128, 1)">1</span> git  git   <span style="color: rgba(128, 0, 128, 1)">176</span> 10月 <span style="color: rgba(128, 0, 128, 1)">16</span> <span style="color: rgba(128, 0, 128, 1)">2014</span><span style="color: rgba(0, 0, 0, 1)"> .bash_profile
</span>-rw-r--r--. <span style="color: rgba(128, 0, 128, 1)">1</span> git  git   <span style="color: rgba(128, 0, 128, 1)">124</span> 10月 <span style="color: rgba(128, 0, 128, 1)">16</span> <span style="color: rgba(128, 0, 128, 1)">2014</span><span style="color: rgba(0, 0, 0, 1)"> .bashrc
drwxr</span>-xr-x. <span style="color: rgba(128, 0, 128, 1)">2</span> git  git  <span style="color: rgba(128, 0, 128, 1)">4096</span> 11月 <span style="color: rgba(128, 0, 128, 1)">12</span> <span style="color: rgba(128, 0, 128, 1)">2010</span><span style="color: rgba(0, 0, 0, 1)"> .gnome2
drwxr</span>-xr-x. <span style="color: rgba(128, 0, 128, 1)">4</span> git  git  <span style="color: rgba(128, 0, 128, 1)">4096</span> 5月   <span style="color: rgba(128, 0, 128, 1)">8</span> <span style="color: rgba(128, 0, 128, 1)">12</span>:<span style="color: rgba(128, 0, 128, 1)">22</span><span style="color: rgba(0, 0, 0, 1)"> .mozilla
drwxr</span>-xr-x. <span style="color: rgba(128, 0, 128, 1)">2</span> git  git  <span style="color: rgba(128, 0, 128, 1)">4096</span> 8月  <span style="color: rgba(128, 0, 128, 1)">28</span> <span style="color: rgba(128, 0, 128, 1)">20</span>:<span style="color: rgba(128, 0, 128, 1)">08</span> .ssh</pre>
<div class="cnblogs_code_toolbar"><span class="cnblogs_code_copy"><a href="javascript:void(0);" onclick="copyCnblogsCode(this)" title="复制代码"><img src="./在 Linux 下搭建 Git 服务器_files/copycode.gif" alt="复制代码"></a></span></div></div>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label6"></a></div><h2>⑦ 将客户端公钥导入服务器端 /home/git/.ssh/authorized_keys 文件</h2>
<p>回到 Git Bash 下，导入文件：</p>
<div class="cnblogs_code">
<pre>$ ssh git@<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">56.101</span> <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">cat &gt;&gt; .ssh/authorized_keys</span><span style="color: rgba(128, 0, 0, 1)">'</span> &lt; ~/.ssh/id_rsa.pub</pre>
</div>
<p>需要输入服务器端 git 用户的密码</p>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828230957010-2048402011.png" alt=""></p>
<p>&nbsp;</p>
<p>回到服务器端，查看 .ssh 下是否存在 authorized_keys 文件：</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">[root@localhost git]# cd .ssh
[root@localhost .ssh]# ll
总用量 </span><span style="color: rgba(128, 0, 128, 1)">4</span>
-rw-rw-r--. <span style="color: rgba(128, 0, 128, 1)">1</span> git git <span style="color: rgba(128, 0, 128, 1)">398</span> 8月  <span style="color: rgba(128, 0, 128, 1)">28</span> <span style="color: rgba(128, 0, 128, 1)">20</span>:<span style="color: rgba(128, 0, 128, 1)">08</span> authorized_keys</pre>
</div>
<p>可以查看一下是否是客户端生成的公钥。</p>
<p>&nbsp;</p>
<p><strong><span style="color: rgba(255, 0, 0, 1)">重要：</span></strong></p>
<p><strong><span style="color: rgba(255, 0, 0, 1)">修改 .ssh 目录的权限为 700</span></strong></p>
<p><strong><span style="color: rgba(255, 0, 0, 1)">修改 .ssh/authorized_keys 文件的权限为 600</span></strong></p>
<div class="cnblogs_code">
<pre>[root@localhost git]# chmod <span style="color: rgba(128, 0, 128, 1)">700</span><span style="color: rgba(0, 0, 0, 1)"> .ssh
[root@localhost git]# cd .ssh
[root@localhost .ssh]# chmod </span><span style="color: rgba(128, 0, 128, 1)">600</span> authorized_keys </pre>
</div>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label7"></a></div><h2>⑧ 客户端再次&nbsp;clone 远程仓库</h2>
<div class="cnblogs_code">
<pre>$ git clone git@<span style="color: rgba(128, 0, 128, 1)">192.168</span>.<span style="color: rgba(128, 0, 128, 1)">56.101</span>:/home/data/git/gittest.git</pre>
</div>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828232005724-1805448371.png" alt=""></p>
<p>&nbsp;</p>
<p>查看客户端项目目录：</p>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828232049743-1094594088.png" alt="" width="887" height="342"></p>
<p>&nbsp;</p>
<p>项目已经 clone 了。</p>
<p>&nbsp;</p>
<p>也可以使用 tortoiseGit 客户端来管理项目：</p>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828232607719-1403152861.png" alt="" width="884" height="509"></p>
<p>clone</p>
<p><img src="./在 Linux 下搭建 Git 服务器_files/534303-20160828232757086-2087480963.png" alt=""></p>
<p>&nbsp;</p>
<div style="text-align: right"><a href="https://www.cnblogs.com/dee0912/p/5815267.html#_labelTop">回到顶部</a><a name="_label8"></a></div><h2>⑨ 禁止 git 用户 ssh 登录服务器</h2>
<p>之前在服务器端创建的 git 用户不允许 ssh 登录服务器</p>
<p>编辑 /etc/passwd</p>
<p>找到：</p>
<div class="cnblogs_code">
<pre>git:x:<span style="color: rgba(128, 0, 128, 1)">502</span>:<span style="color: rgba(128, 0, 128, 1)">504</span>::/home/git:/bin/bash</pre>
</div>
<p>修改为</p>
<div class="cnblogs_code">
<pre>git:x:<span style="color: rgba(128, 0, 128, 1)">502</span>:<span style="color: rgba(128, 0, 128, 1)">504</span>::/home/git:/bin/git-shell</pre>
</div>
<p>此时&nbsp;git 用户可以正常通过 ssh 使用 git，但无法通过 ssh 登录系统。</p>
<p>&nbsp;</p>
<p>参考：<a href="http://blog.csdn.net/wave_1102/article/details/47779401" target="_blank">在CentOS下搭建自己的Git服务器</a></p>
</div>
<div id="MySignature"></div>
<div class="clear"></div>
<div id="blog_post_info_block">
<div id="EntryTag">
    标签: 
            <a href="https://www.cnblogs.com/dee0912/tag/git/">git</a></div>

    <div id="blog_post_info">
<div id="green_channel">
        <a href="javascript:void(0);" id="green_channel_digg" onclick="DiggIt(5815267,cb_blogId,1);green_channel_success(this,&#39;谢谢推荐！&#39;);">好文要顶</a>
        <a id="green_channel_follow" onclick="follow(&#39;b4fd652a-8fc9-e211-8d02-90b11c0b17d6&#39;);" href="javascript:void(0);">关注我</a>
    <a id="green_channel_favorite" onclick="AddToWz(cb_entryId);return false;" href="javascript:void(0);">收藏该文</a>
    <a id="green_channel_weibo" href="javascript:void(0);" title="分享至新浪微博" onclick="ShareToTsina()"><img src="./在 Linux 下搭建 Git 服务器_files/icon_weibo_24.png" alt=""></a>
    <a id="green_channel_wechat" href="javascript:void(0);" title="分享至微信" onclick="shareOnWechat()"><img src="./在 Linux 下搭建 Git 服务器_files/wechat.png" alt=""></a>
</div>
<div id="author_profile">
    <div id="author_profile_info" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/dee0912/" target="_blank"><img src="./在 Linux 下搭建 Git 服务器_files/20160707124938.png" class="author_avatar" alt=""></a>
        <div id="author_profile_detail" class="author_profile_info">
            <a href="https://home.cnblogs.com/u/dee0912/">deee</a><br>
            <a href="https://home.cnblogs.com/u/dee0912/followees/">关注 - 7</a><br>
            <a href="https://home.cnblogs.com/u/dee0912/followers/">粉丝 - 99</a>
        </div>
    </div>
    <div class="clear"></div>
    <div id="author_profile_honor"></div>
    <div id="author_profile_follow">
                <a href="javascript:void(0);" onclick="follow(&#39;b4fd652a-8fc9-e211-8d02-90b11c0b17d6&#39;);return false;">+加关注</a>
    </div>
</div>
<div id="div_digg">
    <div class="diggit" onclick="votePost(5815267,&#39;Digg&#39;)">
        <span class="diggnum" id="digg_count">26</span>
    </div>
    <div class="buryit" onclick="votePost(5815267,&#39;Bury&#39;)">
        <span class="burynum" id="bury_count">0</span>
    </div>
    <div class="clear"></div>
    <div class="diggword" id="digg_tips">
    </div>
</div>

<script type="text/javascript">
    currentDiggType = 0;
</script></div>
    <div class="clear"></div>
    <div id="post_next_prev">

    <a href="https://www.cnblogs.com/dee0912/p/5795511.html" class="p_n_p_prefix">« </a> 上一篇：    <a href="https://www.cnblogs.com/dee0912/p/5795511.html" title="发布于 2016-08-22 14:33">使用 SVN Hook 实现服务器端代码自动更新</a>
    <br>
    <a href="https://www.cnblogs.com/dee0912/p/5940288.html" class="p_n_p_prefix">» </a> 下一篇：    <a href="https://www.cnblogs.com/dee0912/p/5940288.html" title="发布于 2016-10-08 21:44">PHP 使用 curl_* 系列函数和 curl_multi_* 系列函数进行多接口调用时的性能对比</a>

</div>
</div>
            </div>
            <div class="postDesc">posted @ 
<span id="post-date">2016-08-28 23:36</span>&nbsp;
<a href="https://www.cnblogs.com/dee0912/">deee</a>&nbsp;
阅读(<span id="post_view_count">108375</span>)&nbsp;
评论(<span id="post_comment_count">14</span>)&nbsp;
<a href="https://i.cnblogs.com/EditPosts.aspx?postid=5815267" rel="nofollow">编辑</a>&nbsp;
<a href="javascript:void(0)" onclick="AddToWz(5815267);return false;">收藏</a></div>
        </div>
        <script src="./在 Linux 下搭建 Git 服务器_files/highlight.min.js"></script>
<script>markdown_highlight();</script>
<script>
    var allowComments = false, cb_blogId = 196695, cb_blogApp = 'dee0912', cb_blogUserGuid = 'b4fd652a-8fc9-e211-8d02-90b11c0b17d6';
    var cb_entryId = 5815267, cb_entryCreatedDate = '2016-08-28 23:36', cb_postType = 1;
    updatePostStats(
        [cb_entryId],
        function(id, count) { $("#post_view_count").text(count) },
        function(id, count) { $("#post_comment_count").text(count) })
</script>
        <a name="!comments"></a>
<div id="blog-comments-placeholder">

<div id="comment_pager_top">
    
</div>


<div class="feedback_area_title">评论列表</div>
<div class="feedbackNoItems"></div>

    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3536957" class="layer">#1楼</a>
<a name="3536957" id="comment_anchor_3536957"></a>

            <!-- PostDate -->
            
<span class="comment_date">2016-10-20 15:26</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3536957" href="https://home.cnblogs.com/u/911276/" target="_blank">ck2016</a>

            <div class="feedbackCon">
                
<div id="comment_body_3536957" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    楼主辛苦了，谢谢
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3536957, &#39;Digg&#39;, this.parentElement, false);">
                支持(1)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3536957, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3644941" class="layer">#2楼</a>
<a name="3644941" id="comment_anchor_3644941"></a>

            <!-- PostDate -->
            
<span class="comment_date">2017-03-19 15:53</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3644941" href="https://www.cnblogs.com/zhouqiren/" target="_blank">mrossZ</a>

            <div class="feedbackCon">
                
<div id="comment_body_3644941" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    很好，按照楼主所写的 搭建成功了。多谢！
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3644941, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3644941, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        <span id="comment_3644941_avatar" style="display:none">
            https://pic.cnblogs.com/face/871928/20160103210017.png
        </span>

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3701276" class="layer">#3楼</a>
<a name="3701276" id="comment_anchor_3701276"></a>

            <!-- PostDate -->
            
<span class="comment_date">2017-05-26 10:55</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3701276" href="https://home.cnblogs.com/u/1172679/" target="_blank">ralu</a>

            <div class="feedbackCon">
                
<div id="comment_body_3701276" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    按照博主的搭建成功后，下载了tortoisegit为什么每次拉取和推送都要输入密码，想问下博主到底是哪里出问题了
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3701276, &#39;Digg&#39;, this.parentElement, false);">
                支持(2)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3701276, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3704338" class="layer">#4楼</a>
<a name="3704338" id="comment_anchor_3704338"></a>

            <!-- PostDate -->
            
<span class="comment_date">2017-05-31 18:04</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3704338" href="https://www.cnblogs.com/Sungeek/" target="_blank">Tse先生</a>

            <div class="feedbackCon">
                
<div id="comment_body_3704338" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    根据楼主的说明整了一下,确实可以了!非常感谢,膜拜,我能转载吧?
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3704338, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3704338, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        <span id="comment_3704338_avatar" style="display:none">
            https://pic.cnblogs.com/face/872610/20200507113210.png
        </span>

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3705529" class="layer">#5楼</a>
<a name="3705529" id="comment_anchor_3705529"></a>

            <!-- PostDate -->
            
<span class="comment_date">2017-06-02 12:18</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3705529" href="https://www.cnblogs.com/Sungeek/" target="_blank">Tse先生</a>

            <div class="feedbackCon">
                
<div id="comment_body_3705529" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    博主,请问这个git的权限管理方面..知道怎么管理么?
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3705529, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3705529, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        <span id="comment_3705529_avatar" style="display:none">
            https://pic.cnblogs.com/face/872610/20200507113210.png
        </span>

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3719115" class="layer">#6楼</a>
<a name="3719115" id="comment_anchor_3719115"></a>

            <!-- PostDate -->
            
<span class="comment_date">2017-06-21 09:26</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3719115" href="https://www.cnblogs.com/zx-n/" target="_blank">在路上的牛小牛</a>

            <div class="feedbackCon">
                
<div id="comment_body_3719115" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    步骤⑥服务器端 Git 打开 RSA 认证  是怎么操作的？
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3719115, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3719115, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        <span id="comment_3719115_avatar" style="display:none">
            https://pic.cnblogs.com/face/823294/20170901143356.png
        </span>

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3768662" class="layer">#7楼</a>
<a name="3768662" id="comment_anchor_3768662"></a>

            <!-- PostDate -->
            
<span class="comment_date">2017-08-28 17:24</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3768662" href="https://home.cnblogs.com/u/1216670/" target="_blank">无敌是多么的寂寞！</a>

            <div class="feedbackCon">
                
<div id="comment_body_3768662" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    做的非常好<br>Git常用命令大全:<a href="http://t.cn/RCwqbg9" target="_blank">http://t.cn/RCwqbg9</a>
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3768662, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3768662, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#3996351" class="layer">#8楼</a>
<a name="3996351" id="comment_anchor_3996351"></a>

            <!-- PostDate -->
            
<span class="comment_date">2018-06-12 10:03</span>


            <!--NameLink-->
            
        <a id="a_comment_author_3996351" href="https://www.cnblogs.com/Eastterry2012/" target="_blank">麦田金龟子</a>

            <div class="feedbackCon">
                
<div id="comment_body_3996351" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    谢谢楼主，后续有没有怎么管理git服务器的文章
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(3996351, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(3996351, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#4085559" class="layer">#9楼</a>
<a name="4085559" id="comment_anchor_4085559"></a>

            <!-- PostDate -->
            
<span class="comment_date">2018-10-10 14:57</span>


            <!--NameLink-->
            
        <a id="a_comment_author_4085559" href="https://home.cnblogs.com/u/1445269/" target="_blank">嫖虫</a>

            <div class="feedbackCon">
                
<div id="comment_body_4085559" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    我使用小乌龟克隆的时候，成功倒是成功克隆了，可是一完成就弹出个小窗口提示：参数错误！这是什么原有呢？
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4085559, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(4085559, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#4092727" class="layer">#10楼</a>
<a name="4092727" id="comment_anchor_4092727"></a>

            <!-- PostDate -->
            
<span class="comment_date">2018-10-18 10:28</span>


            <!--NameLink-->
            
        <a id="a_comment_author_4092727" href="https://www.cnblogs.com/rangers/" target="_blank">列兵许四多</a>

            <div class="feedbackCon">
                
<div id="comment_body_4092727" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    已加关注，非常详细，楼主辛苦。。。
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4092727, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(4092727, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#4132151" class="layer">#11楼</a>
<a name="4132151" id="comment_anchor_4132151"></a>

            <!-- PostDate -->
            
<span class="comment_date">2018-12-05 15:14</span>


            <!--NameLink-->
            
        <a id="a_comment_author_4132151" href="https://home.cnblogs.com/u/1548768/" target="_blank">勿悔125</a>

            <div class="feedbackCon">
                
<div id="comment_body_4132151" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    ssh git@192.168.56.101 'cat &gt;&gt; .ssh/authorized_keys' &lt; ~/.ssh/id_rsa.pub<br><br>这一步一直提示密码错误，实际上密码没有错，试过了好几次没解决，求教<br><br>错误信息：Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4132151, &#39;Digg&#39;, this.parentElement, false);">
                支持(3)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(4132151, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#4179260" class="layer">#12楼</a>
<a name="4179260" id="comment_anchor_4179260"></a>

            <!-- PostDate -->
            
<span class="comment_date">2019-02-14 11:11</span>


            <!--NameLink-->
            
        <a id="a_comment_author_4179260" href="https://www.cnblogs.com/wswind/" target="_blank">wswind</a>

            <div class="feedbackCon">
                
<div id="comment_body_4179260" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    详细，清晰，谢谢
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4179260, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(4179260, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        <span id="comment_4179260_avatar" style="display:none">
            https://pic.cnblogs.com/face/1114902/20200228175431.png
        </span>

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#4245888" class="layer">#13楼</a>
<a name="4245888" id="comment_anchor_4245888"></a>

            <!-- PostDate -->
            
<span class="comment_date">2019-05-01 21:58</span>


            <!--NameLink-->
            
        <a id="a_comment_author_4245888" href="https://home.cnblogs.com/u/1204359/" target="_blank">1417743769</a>

            <div class="feedbackCon">
                
<div id="comment_body_4245888" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    <a href="https://www.cnblogs.com/dee0912/p/5815267.html#4132151" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,4132151);">@</a>
勿悔125<br>我的也是这样，你解决了吗<br>$ ssh git@60.205.212.254 'cat &gt;&gt; .ssh/authorized_keys' &lt; ~/.ssh/id_rsa.pub<br>git@60.205.212.254's password:<br>bash: .ssh/authorized_keys: No such file or directory
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4245888, &#39;Digg&#39;, this.parentElement, false);">
                支持(1)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(4245888, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>
    <div class="feedbackItem">
        <div class="feedbackListSubtitle">
            <div class="feedbackManage">
                &nbsp;&nbsp;
                

<span class="comment_actions">
    
    
    
    
</span>


            </div>
            <!-- Title -->
            
<a href="https://www.cnblogs.com/dee0912/p/5815267.html#4419363" class="layer">#14楼</a>
<a name="4419363" id="comment_anchor_4419363"></a>
    <span id="comment-maxId" style="display: none">4419363</span>
    <span id="comment-maxDate" style="display: none">2019/11/8 下午1:30:58</span>

            <!-- PostDate -->
            
<span class="comment_date">2019-11-08 13:30</span>


            <!--NameLink-->
            
        <a id="a_comment_author_4419363" href="https://home.cnblogs.com/u/1862067/" target="_blank">魔法之裤</a>

            <div class="feedbackCon">
                
<div id="comment_body_4419363" data-format-type="Ubb" class="blog_comment_body cnblogs-ubb">
    <a href="https://www.cnblogs.com/dee0912/p/5815267.html#4245888" title="查看所回复的评论" onclick="commentManager.renderComments(0,50,4245888);">@</a>
1417743769<br>我摸索出来了，看这个
</div>
        <div class="comment_vote">
            <span class="comment_error" style="color: red"></span>
            <a href="javascript:void(0);" class="comment_digg" onclick="return voteComment(4419363, &#39;Digg&#39;, this.parentElement, false);">
                支持(0)
            </a>
            <a href="javascript:void(0);" class="comment_burry" onclick="return voteComment(4419363, &#39;Bury&#39;, this.parentElement, false);">
                反对(0)
            </a>
        </div>
        

            </div>
        </div>
    </div>


<div id="comment_pager_bottom">
    
</div>
</div>
<div id="comment_form" class="commentform">
    <a name="commentform"></a>
    <div id="divCommentShow"></div>
    <div id="comment_nav"><span id="span_refresh_tips"></span><a href="javascript:void(0);" onclick="return RefreshCommentList();" id="lnk_RefreshComments" runat="server" clientidmode="Static">刷新评论</a><a href="https://www.cnblogs.com/dee0912/p/5815267.html#" onclick="return RefreshPage();">刷新页面</a><a href="https://www.cnblogs.com/dee0912/p/5815267.html#top">返回顶部</a></div>
    <div id="comment_form_container" style="visibility: visible;">（评论功能已被禁用）</div>
    <div class="ad_text_commentbox" id="ad_text_under_commentbox"></div>
    <div id="ad_t2"></div>
    <div id="opt_under_post"></div>
    <div id="cnblogs_c1" class="c_ad_block">
        <div id="div-gpt-ad-1592365906576-0" style="width: 300px; height: 250px;"></div>
    </div>
    <div id="under_post_news"></div>
    <div id="cnblogs_c2" class="c_ad_block">
        <div id="div-gpt-ad-1592366332455-0" style="width: 468px; height: 60px;"></div>
    </div>
    <div id="under_post_kb">
<div class="itnews c_ad_block">
    <b>最新 IT 新闻</b>:
    <br>
 ·          <a href="https://news.cnblogs.com/n/684370/" target="_blank">加码中视频：腾讯视频的内卷与扩张</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/684369/" target="_blank">马斯克成为2020年财富增加最多的人：中国首富位列第三</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/684367/" target="_blank">互联网在2020：默片里围猎，黄昏里哀愁</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/684366/" target="_blank">谁在贩卖“教育焦虑”？</a>
        <br>
 ·          <a href="https://news.cnblogs.com/n/684365/" target="_blank">中芯国际公告称梁孟松仍担任联席CEO 曾提出辞职</a>
        <br>
    » <a href="https://news.cnblogs.com/" title="IT 新闻" target="_blank">更多新闻...</a>
</div></div>
    <div id="HistoryToday" class="c_ad_block"></div>
    <script type="text/javascript">
       var commentManager = new blogCommentManager();
       commentManager.renderComments(0);
       fixPostBody();
       deliverBigBanner();
setTimeout(function() { incrementViewCount(cb_entryId); }, 50);       deliverT2();
       deliverC1C2();
       loadNewsAndKb();
       loadBlogSignature();
LoadPostCategoriesTags(cb_blogId, cb_entryId);       LoadPostInfoBlock(cb_blogId, cb_entryId, cb_blogApp, cb_blogUserGuid);
       GetPrevNextPost(cb_entryId, cb_blogId, cb_entryCreatedDate, cb_postType);
       loadOptUnderPost();
       GetHistoryToday(cb_blogId, cb_blogApp, cb_entryCreatedDate);
   </script>
</div>

    </div>
</div>
            </div>
        </div>

        <div id="sideBar">
            <div id="sideBarMain">
                
<div id="sidebar_c3"></div>
                <div id="calendar"><div id="blog-calendar" style="display:none"></div></div>                
                <script>loadBlogDefaultCalendar();</script>
                <div id="leftcontentcontainer">
                    <!-- begin:SingleColumn -->
                    <div id="blog-sidecolumn"><!-- 搜索 -->
<div id="sidebar_search" class="sidebar-block">
    
</div>

<!-- 常用链接 -->


<!-- 最新随笔 -->


<!-- 我的标签 -->


<!-- 积分与排名 -->


<!-- 随笔分类、随笔档案、文章分类、新闻分类、相册、链接 -->
<div id="sidebar_categories">

</div>

<!-- 最新评论 -->



<!-- 阅读排行榜 -->


<!-- 评论排行榜 -->


<!-- 推荐排行榜 -->
</div>
                    <script>loadBlogSideColumn();</script>
                    <!-- end:  SingleColumn -->
                </div>
            </div>
        </div>
        <div class="clear"></div>
    </div>
    <div class="clear"></div>
    <div id="footer">
        <!--done-->
Copyright © 2020 deee
<br><span id="poweredby">Powered by .NET 5.0 on Kubernetes</span>

    </div>
</div>

    <div id="page_end_html">
        <div style="text-align:center">访客数：<img border="0" src="./在 Linux 下搭建 Git 服务器_files/counter.php" alt="AmazingCounters.com">
<br>
2016/05/17 起统计</div>

<script language="javascript" type="text/javascript">

// 生成目录索引列表

function GenerateContentList()
{
    var mainContent = $('#cnblogs_post_body');
    var h2_list = $('#cnblogs_post_body h2');//如果你的章节标题不是h2,只需要将这里的h2换掉即可

    if(mainContent.length < 1)
        return;
 
    if(h2_list.length>0)
    {
        var content = '<a name="_labelTop"></a>';
        content += '<div id="navCategory">';
        content += '<p style="font-size:18px"><b>目录</b></p>';
        content += '<ul>';
        for(var i=0; i<h2_list.length; i++)
        {
            var go_to_top = '<div style="text-align: right"><a href="#_labelTop">回到顶部</a><a name="_label' + i + '"></a></div>';
            $(h2_list[i]).before(go_to_top);
            
            var h3_list = $(h2_list[i]).nextAll("h3");
            var li3_content = '';
            for(var j=0; j<h3_list.length; j++)
            {
                var tmp = $(h3_list[j]).prevAll('h2').first();
                if(!tmp.is(h2_list[i]))
                    break;
                var li3_anchor = '<a name="_label' + i + '_' + j + '"></a>';
                $(h3_list[j]).before(li3_anchor);
                li3_content += '<li><a href="#_label' + i + '_' + j + '">' + $(h3_list[j]).text() + '</a></li>';
            }
            
            var li2_content = '';
            if(li3_content.length > 0)
                li2_content = '<li><a href="#_label' + i + '">' + $(h2_list[i]).text() + '</a><ul>' + li3_content + '</ul></li>';
            else
                li2_content = '<li><a href="#_label' + i + '">' + $(h2_list[i]).text() + '</a></li>';
            content += li2_content;
        }
        content += '</ul>';
        content += '</div><p>&nbsp;</p>';
        content += '<p style="font-size:18px"><b>正文</b></p>';
        if($('#cnblogs_post_body').length != 0 )
        {
            $($('#cnblogs_post_body')[0]).prepend(content);
        }
    }   
}

GenerateContentList();
</script>
    </div>


<script type="text/javascript">
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?9efa11a81941b7632a7b370e05d3f77c";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><div class="scroll-helper ui-draggable"><a class="box top-box" href="javascript:void(0);" title="回到顶部">顶部</a><a class="box bottom-box" href="javascript:void(0);" title="回到底部">底部</a><a class="box prev-box" href="javascript:void(0);" title="向上一屏">向上</a><a class="box next-box" href="javascript:void(0);" title="向下一屏">向下</a><a class="box setting-box" href="javascript:void(0)" title="设置" style="opacity: 0.8;">S</a><ul class="context-menu" style="display: none;"><li><a href="javascript:void(0);" class="close">关闭</a></li><li><a href="javascript:void(0);" class="save-position">保存位置</a></li><li><a href="javascript:void(0);" class="auto-scroll">开启自动滚动</a></li><li><a href="javascript:void(0);" class="not-in-this-page">不在该网页使用</a></li><li><a href="javascript:void(0);" class="not-in-this-website">不在该网站使用</a></li></ul></div></body></html>